package com.apache.database.model;

import com.apache.tools.StrUtil;

import java.io.Serializable;
import java.util.Random;

/**
 * description:
 *
 * @author dyh 创建时间：2018年09月29日
 */
public class Task implements Serializable {

    protected String className;//定时任务类
    protected String methodName;//方法名
    protected String taskType;//任务类型
    protected Long intervalType;//间隔类型:1按天间隔,0按小时间隔
    protected Long hour;//小时
    protected Long minute;//分钏
    protected Long second;//秒
    protected String description = "";//描述
    protected Integer startTime = 0;//开始时点(0~23)
    protected Integer endTime = 0;//结束时点(0~23)
    protected Integer taskStatus = 0;//状态;
    protected boolean openStart = false;//任务是否开启

    protected String taskKey;//线程代号

    public String getTaskKey() {
        return taskKey;
    }

    public void setTaskKey(String taskKey) {
        this.taskKey = taskKey;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getMethodName() {
        return methodName;
    }

    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public String getTaskType() {
        return taskType;
    }

    public void setTaskType(String taskType) {
        this.taskType = taskType;
    }

    public long getIntervalType() {
        return intervalType;
    }

    public void setIntervalType(long intervalType) {
        this.intervalType = intervalType;
    }

    public long getHour() {
        return hour;
    }

    public void setHour(Long hour) {
        this.hour = hour;
    }

    public long getMinute() {
        return minute;
    }

    public void setMinute(Long minute) {
        this.minute = minute;
    }

    public long getSecond() {
        return second;
    }

    public void setSecond(Long second) {
        this.second = second;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getStartTime() {
        return startTime;
    }

    public void setStartTime(Integer startTime) {
        this.startTime = startTime;
    }

    public int getEndTime() {
        return endTime;
    }

    public void setEndTime(Integer endTime) {
        this.endTime = endTime;
    }

    public int getTaskStatus() {
        return taskStatus;
    }

    public void setTaskStatus(Integer taskStatus) {
        this.taskStatus = taskStatus;
    }

    public boolean isOpenStart() {
        return openStart;
    }

    public void setOpenStart(boolean openStart) {
        this.openStart = openStart;
    }

    /**
     * 按类型与长度生成随机数
     *
     * @param maxNum 随机数的长度
     * @return
     * @author Hou Dayu
     */
    public String getRandomStr(int maxNum) {
        String numStr = "ab0cde2fgh8ig6klm9no3pqr7stu4vws5yz1";
        int count = 36;
        StringBuilder str = new StringBuilder("");
        int intRd = 0; //存放随机数
        boolean[] bool = new boolean[count];
        Random rdm = new Random();
        for (int i = 0; i < maxNum; i++) {//随机排序
            do {
                intRd = rdm.nextInt(count); //假如产生的数相同继续循环
            } while (bool[intRd]);
            bool[intRd] = true;
            str.append(numStr.charAt(intRd));
        }
        return str.toString();
    }

}
